package oop.core.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

import oop.core.entity.DerivedStats;
/**
 * This represents the Stat Panel 
 * of the game
 * 
 *
 */
public class StatsPanel extends SizeablePanel {

	private static final Dimension SIZE = new Dimension(400, 130);
	private static final Point LOCATION = new Point(600, 0);
	
	private DerivedStats stats;
	
	public StatsPanel()
	{
		super(LOCATION, SIZE);
	}
	
	public void takeStats(DerivedStats stats)
	{
		this.stats = stats;
	}
	
	protected void paintComponent(Graphics g)
	{
//		System.out.println("Painting StatsPanel");
		g.setColor(Color.BLACK);
		g.fillRect(0, 0, SIZE.width, SIZE.height);
		
		int currentHP = stats.getHP();
		int maxHP = stats.getMaxHP();
		double percentHP = currentHP/(double)maxHP;
//		System.out.println("HP : " + currentHP + "/" + maxHP + " = " + percentHP);
		
		int currentMP = stats.getMP();
		int maxMP = stats.getMaxMP();
		double percentMP = currentMP/(double)maxMP;
//		System.out.println("MP : " + currentMP + "/" + maxMP + " = " + percentMP);
		
		g.setColor(Color.RED);
		g.fillRect(0, 0, (int)(SIZE.width*percentHP), 20);
		
		g.setColor(Color.BLUE);
		g.fillRect(0, 20, (int)(SIZE.width*percentMP), 20);
		
		g.setColor(Color.WHITE);
		g.drawString("HP: " + stats.getHP() + " / " + stats.getMaxHP(), 70, 15);
		g.drawString("MP: " + stats.getMP() + " / " + stats.getMaxMP(), 70, 35);
		
		g.drawString("Lives left: " + stats.getLives(), 10, 55);
		g.drawString("Strength: " + stats.getStrength(), 10, 70);
		g.drawString("Agility: " + stats.getAgility(), 10, 85);
		g.drawString("Intellict: " + stats.getIntellect(), 10, 100);
		g.drawString("Hardiness: " + stats.getHardiness(), 10, 115);

		g.drawString("Level: " + stats.getLevel(), 200, 55);
		g.drawString("Experience: " + stats.getEXP() + " / " + stats.getNextLevelExperience(), 200, 70);
		g.drawString("Offense Rating: " + stats.getOffensiveRating(), 200, 85);
		g.drawString("Defense Rating: " + stats.getDefensiveRating(), 200, 100);
		g.drawString("Armor Rating: " + stats.getArmorRating(), 200, 115);
	}
}
